package com.digital.cnzz.zkp.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: jingyajun
 * @date: 2021/4/7
 * @description:
 * @since:
 */
@Getter
@AllArgsConstructor
public enum RuleParamsEnum {
    /* ↓ 指标得分计算参数 ↓ */
    BASIC_VALUE("基础值", "basicValue", "BigDecimal", 1),
    TARGET_VALUE("目标值", "targetValue", "BigDecimal", 1),
    DONE_VALUE("完成值", "doneValue", "BigDecimal", 1),
    SET_POINT("额定分", "setPoint", "BigDecimal", 1),

    /* ↓ 最终得分计算参数 ↓ */
    /**
     * 考评年份
     */
    YEAR_FINAL("考评年份", "year", "String", 2),
    /**
     * 考核类型
     */
    ASSESS_CYCLE_FINAL("考核类型", "assessCycle", "Integer", 2),
    /**
     * 考核场次
     */
    ASSESS_TIME_FINAL("考核场次", "assessTime", "Integer", 2),

    /* ↓ 专项得分计算参数 ↓ */
    /**
     * 考评年份
     */
    YEAR("考评年份", "year", "String", 3),
    /**
     * 专项编号
     */
    PLAN_CODE("专项编号", "evaluationPlanCode", "String", 3),
    /**
     * 考核类型
     */
    ASSESS_CYCLE("考核类型", "assessCycle", "Integer", 3),
    /**
     * 考核场次
     */
    ASSESS_TIME("考核场次", "assessTime", "Integer", 3),
    /**
     * 考评状态
     */
    APPROVE_STATUS("考评状态", "approveStatus", "Integer", 3);


    public static List<RuleParamsEnum> getParamEnums(Integer ruleType) {
        List<RuleParamsEnum> paramsEnums = new ArrayList<>();
        RuleParamsEnum[] values = RuleParamsEnum.values();
        for (RuleParamsEnum value : values) {
            if (value.type.equals(ruleType)) {
                paramsEnums.add(value);
            }
        }
        return paramsEnums;
    }

    public static String getName(Integer ruleType, String code) {
        RuleParamsEnum[] values = RuleParamsEnum.values();
        for (RuleParamsEnum value : values) {
            if (value.ruleType.equals(ruleType) && value.code.equals(code)) {
                return value.name;
            }
        }
        return null;
    }

    private String name;
    private String code;
    private String type;
    /**
     * 规则类型:1指标得分计算,2最总得分计算,3专项得分计算
     */
    private Integer ruleType;

}
